<?php $this->_extends('../_layouts/default_layout'); ?>
<?php $this->_block('contents'); ?>
<script type="text/javascript">
$(function(){
	$(".datepicker").datepicker({dateFormat: 'yy-mm-dd', changeMonth: true});
	$(".show_status").colorbox({width: "900px", height: "600px", iframe: true});
	$(".note_icon").colorbox({width: "50%", height: "50%", iframe: true});
	$(".show_detail").toggle(function(){
		$(this).parent().parent().next().show();
	},function(){
		$(this).parent().parent().next().hide();
	});
	$(".more_click").mouseover(function(){
		$(this).next().show();
	}).mouseout(function(){
		$(this).next().hide();
	});
	$(".more_content").mouseover(function(){
		$(this).show();
	}).mouseout(function(){
		$(this).hide();
	});
	$(".delete_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		if ( ! confirm('是否确认删除？'))
		{
			return false;
		}
		window.location.href = "<?=url('Product::Image/Delete')?>&id=" + id;
	});
	$(".requirement_confirmed_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		$("#dialog_requirement_confirmed").find("input[name='id']").val(id);
		$("#dialog_requirement_confirmed").dialog("open");
		$("#dialog_requirement_confirmed").find("input[type='submit']").focus();
	});
	$("#dialog_requirement_confirmed").dialog({autoOpen: false, modal: true, height: 160, width: 300});
	$(".is_photo_confirmed").change(function(){
		if ($(this).is(":checked"))
		{
			$(this).parent().next().show();
		}
		else
		{
			$(this).parent().next().hide();
		}
	});
	$(".photo_accepted_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		if ( ! confirm('是否确认修改状态为：拍摄接受？'))
		{
			return false;
		}
		window.location.href = "<?=url('Product::Image/PhotoAccepted')?>&id=" + id;
	});
	$(".photo_completed_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		$("#dialog_photo_path").find("input[name='id']").val(id);
		$("#dialog_photo_path").dialog("open");
	});
	$(".rephoto_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		$("#dialog_rephoto_reason").find("input[name='id']").val(id);
		$("#dialog_rephoto_reason").dialog("open");
	});
	$("#dialog_rephoto_reason").dialog({autoOpen: false, modal: true, height: 200, width: 300});
	$(".rephoto_completed_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		$("#dialog_photo_path").children("form").attr('action', "<?=url('Product::Image/RephotoCompleted')?>");
		$("#dialog_photo_path").find("input[name='id']").val(id);
		$("#dialog_photo_path").dialog("open");
	});
	$("#dialog_photo_path").dialog({autoOpen: false, modal: true, height: 150, width: 300});
	$(".rephoto_accepted_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		if ( ! confirm('是否确认修改状态为：返拍接受？'))
		{
			return false;
		}
		window.location.href = "<?=url('Product::Image/RephotoAccepted')?>&id=" + id;
	});
	$(".edit_photo_path_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		$("#dialog_photo_path").children("form").attr('action', "<?=url('Product::Image/PhotoPathSave')?>");
		$("#dialog_photo_path").find("input[name='id']").val(id);
		$("#dialog_photo_path").dialog("open");
	});
	$(".edit_rephoto_reason_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		$("#dialog_rephoto_reason").children("form").attr('action', "<?=url('Product::Image/RephotoReasonSave')?>");
		$("#dialog_rephoto_reason").find("input[name='id']").val(id);
		$("#dialog_rephoto_reason").dialog("open");
	});
	$(".photo_confirmed_click").click(function(){
		var id = $(this).parent().parent().parent().parent().children("input[name='id']").val();
		if ( ! confirm('是否确认修改状态为：拍摄完成？'))
		{
			return false;
		}
		window.location.href = "<?=url('Product::Image/PhotoConfirmed')?>&id=" + id;
	});
});
</script>
<style type="text/css">
.more_content {
	position: absolute;
	top: 2px;
	left: 24px;
	width: 60px;
	background-color: #eeeeee;
	z-index: 100;
	display: none;
	border: 1px solid;
}
</style>
<fieldset><legend>查询条件</legend>
<form>
<?php include(Q::ini('custom_system/elements_dir') . 'searchform_element.php');?>
<table class="form_table">
	<tr>
		<th>创建时间</th>
		<td>
			<input type="text" class="datepicker" name="create_time_begin" value="<?=isset($_GET['create_time_begin']) ? $_GET['create_time_begin'] : ''?>" /> to 
			<input type="text" class="datepicker" name="create_time_end" value="<?=isset($_GET['create_time_end']) ? $_GET['create_time_end'] : ''?>" /> 
		</td>
	</tr>
	<tr>
		<th>需求人员</th>
		<td>
			<select name="requirement_user_id">
				<option value="">请选择..</option>
				<?foreach ($user as $u):?>
				<option value="<?=$u['id']?>" <?=isset($_GET['requirement_user_id']) && $_GET['requirement_user_id'] == $u['id'] ? 'selected=selected' : '';?>"><?=$u['name']?></option>
				<?endforeach;?>
			</select>
		</td>
	</tr>
	<tr>
		<th>名称</th>
		<td><input type="text" name="name" value="<?=isset($_GET['name']) ? $_GET['name'] : ''?>" /></td>
	</tr>
	<tr>
		<th>类型</th>
		<td>
			<?foreach (Q::ini('custom_flag/image_requirement_type') as $t):?>
			<label><input type="checkbox" name="type[<?=$t['value']?>]" value="<?=$t['value']?>" <?=isset($_GET['type']) && in_array($t['value'], $_GET['type']) ? 'checked="checked"' : ''?> /> <?=$t['name']?></label>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<th>操作状态</th>
		<td>
			<?foreach (Q::ini('custom_flag/image_requirement_handle_status') as $hs):?>
			<?if ($hs['value'] <= Q::ini('custom_flag/image_requirement_handle_status/photo_confirmed/value')):?>
			<label><input type="checkbox" name="handle_status[<?=$hs['value']?>]" value="<?=$hs['value']?>" <?=isset($_GET['handle_status']) && in_array($hs['value'], $_GET['handle_status']) ? 'checked="checked"' : ''?> /> <?=$hs['name']?></label>
			<?endif;?>
			<?endforeach;?>
		</td>
	</tr>
	<tr>
		<td colspan="2"><input type="submit" class="button" value="查询" /></td>
	</tr>
</table>
</form>
</fieldset>
<table class="list_table" width="96%">
	<tr>
		<th width="40">ID</th>
		<th>名称</th>
		<th width="40">类型</th>
		<th width="60">操作状态</th>
		<th>创建时间</th>
		<th>创建人</th>
		<th>需求人员</th>
		<th width="200">图片路径</th>
		<th width="100">返拍原因</th>
		<th width="16">备注</th>
		<th width="80">操作</th>
	</tr>
	<?foreach ($requirement as $r):?>
	<tr>
		<td><a class="show_status" href="<?=url('Product::Image/ShowStatus', array('id' => $r['id']))?>">#<?=$r['id']?></a></td>
		<td><?=$r['name']?></td>
		<td><?=Helper_BSS_Normal::getIniOne('image_requirement_type', 'value', $r['type'], 'name')?></td>
		<td><?=Helper_BSS_Normal::getIniOne('image_requirement_handle_status', 'value', $r['handle_status'], 'name')?></td>
		<td title="创建时间：<?=$r['create_time']?> <?=$r['requirement_user_name'] . "\n"?>
需求确认：<?=$r['requirement_confirmed_time']?> <?=$r['requirement_confirmed_user_name'] . "\n"?>
拍摄接受：<?=$r['photo_accepted_time']?> <?=$r['photo_accepted_user_name'] . "\n"?>
拍摄完成：<?=$r['photo_completed_time']?> <?=$r['photo_completed_user_name'] . "\n"?>
返拍时间：<?=$r['rephoto_time']?> <?=$r['rephoto_user_name'] . "\n"?>
返拍接受：<?=$r['rephoto_accepted_time']?> <?=$r['rephoto_accepted_user_name'] . "\n"?>
返拍完成：<?=$r['rephoto_completed_time']?> <?=$r['rephoto_completed_user_name'] . "\n"?>
拍摄确认：<?=$r['photo_confirmed_time']?> <?=$r['photo_confirmed_user_name'] . "\n"?>"><?=$r['create_time']?></td>
		<td><?=$r['create_user_name']?></td>
		<td><?=$r['requirement_user_name']?></td>
		<td style="word-break: break-all"><?=$r['photo_path']?></td>
		<td><?=$r['rephoto_reason']?></td>
		<td><a class="note_icon" href="<?=url('Product::Image/RequirementNote', array('id' => $r['id']))?>"></a></td>
		<td>
			<input type="hidden" name="id" value="<?=$r['id']?>" />
			<a href="javascript: void(0);" class="show_detail">查看</a>
			<div style="float: right; position:relative;">
			<a class="more_click">更多&or;</a>
			<ul class="more_content">
				<?if ($r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/new/value')):?>
				<li><a href="<?=url('Product::Image/Edit', array('id' => $r['id']));?>">编辑</a></li>
				<li><a href="javascript: void(0)" class="delete_click">删除</a></li>
				<?else:?>
				<li><font color="#aaaaaa">编辑</font></li>
				<li><font color="#aaaaaa">删除</font></li>
				<?endif;?>
				<?if ($r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/photo_completed/value') || $r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/rephoto_completed/value')):?>
				<li><a href="javascript: void(0)" class="edit_photo_path_click">拍摄路径</a></li>
				<?else:?>
				<li><font color="#aaaaaa">拍摄路径</font></li>
				<?endif;?>
				<?if ($r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/rephoto/value')):?>
				<li><a href="javascript: void(0)" class="edit_rephoto_reason_click">返拍原因</a></li>
				<?else:?>
				<li><font color="#aaaaaa">返拍原因</font></li>
				<?endif;?>
				<?if ($r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/new/value')):?>
				<li><a href="javascript: void(0)" class="requirement_confirmed_click">需求确认</a></li>
				<?endif;?>
				<?if ($r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/requirement_confirmed/value')):?>
				<li><a href="javascript: void(0)" class="photo_accepted_click">拍摄接受</a></li>
				<?endif;?>
				<?if ($r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/photo_accepted/value')):?>
				<li><a href="javascript: void(0)" class="photo_completed_click">拍摄完成</a></li>
				<?endif;?>
				<?if ($r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/photo_completed/value') || $r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/rephoto_completed/value')):?>
				<li><a href="javascript: void(0)" class="rephoto_click">返拍</a></li>
				<li><a href="javascript: void(0)" class="photo_confirmed_click">拍摄确认</a></li>
				<?endif;?>
				<?if ($r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/rephoto/value')):?>
				<li><a href="javascript: void(0)" class="rephoto_accepted_click">返拍接受</a></li>
				<?endif;?>
				<?if ($r['handle_status'] == Q::ini('custom_flag/image_requirement_handle_status/rephoto_accepted/value')):?>
				<li><a href="javascript: void(0)" class="rephoto_completed_click">返拍完成</a></li>
				<?endif;?>
			</ul>
			</div>
		</td>
	</tr>
	<tr style="display: none;">
		<td></td>
		<td colspan="10">
		<table class="list_table" width="100%">
			<tr>
				<td width="60">图片组</td>
				<td>备注</td>
			</tr>
			<?$i = $j = 0;?>
			<?foreach ($r['group'] as $rg):?>
			<?$i++;?>
			<tr>
				<td><?=$i?></td>
				<td align="left"><?=$rg['note']?></td>
			</tr>
			<tr>
				<td></td>
				<td>
				<table class="list_table" width="100%">
					<tr>
						<th width="40"></th>
						<th>产品编号</th>
						<th>产品名称</th>
					</tr>
					<?foreach ($rg['item'] as $rgi):?>
					<?$j++?>
					<tr>
						<td><?=$j?></td>
						<td><?=$rgi['product_number']?></td>
						<td><?=$rgi['product_name']?></td>
					</tr>
					<?endforeach;?>
				</table>
				</td>
			</tr>
			<?endforeach;?>
		</table>
		</td>
	</tr>
	<?endforeach;?>
</table>
<?=$page;?>
<div id="dialog_requirement_confirmed" title="需求确认">
<form method="post" action="<?=url('Product::Image/RequirementConfirmed')?>">
	<p><input type="hidden" name="id" value="" /></p>
	<p>直接指向拍摄确认状态：<input type="checkbox" value="1" name="is_photo_confirmed" class="is_photo_confirmed" /></p>
	<p style="display: none;">图片路径：<input type="text" name="photo_path" value="" size="30" /></p>
	<p><input type="submit" value="需求确认" class="button" /></p>
</form>
</div>
<div id="dialog_photo_path" title="拍摄图片共享路径">
<form method="post" action="<?=url('Product::Image/PhotoCompleted')?>">
	<p><input type="hidden" name="id" value="" /></p>
	<p><input type="text" name="photo_path" value="" size="40" /></p>
	<p><input type="submit" value="提交" class="button" /></p>
</form>
</div>
<div id="dialog_rephoto_reason" title="返拍原因">
<form method="post" action="<?=url('Product::Image/Rephoto')?>">
	<p><input type="hidden" name="id" value="" /></p>
	<p><textarea rows="6" cols="40" name="rephoto_reason"></textarea></p>
	<p><input type="submit" value="提交" class="button" /></p>
</form>
</div>
<?php $this->_endblock(); ?>